//
//  SheetAndAlert.swift
//  NaiCha
//
//  Created by 唐安坤 on 2024/9/12.
//


import SwiftUI
#Preview {
    SheetAndAlert()
}

struct SheetAndAlert: View {
    
    @State var isExpanded = true
    @State var isPresented = false
    @State var selectModel: MyDogModel?
    fileprivate var dataArr = [
        MyDogModel.init(image: "dog01", dogName: "汪汪01"),
        MyDogModel.init(image: "dog02", dogName: "汪汪02"),
        MyDogModel.init(image: "dog03", dogName: "汪汪03"),
        MyDogModel.init(image: "dog04", dogName: "汪汪04"),
        MyDogModel.init(image: "dog05", dogName: "汪汪05"),
        MyDogModel.init(image: "dog06", dogName: "汪汪06")
    ]
    
    var body: some View {
        NavigationStack{
            List {
                ForEach(dataArr) { model in
                    MyDogCardView(image: model.image, name: model.dogName)
                        .onTapGesture {
                        //isPresented = true
                        selectModel = model
                    }
                }
            }.sheet(item: $selectModel) { md in
                NavigetionViewDetail(model: md)
            }
//                .sheet(isPresented: $isPresented, content: {
//                if let model = selectModel, isPresented == true {
//                    
//                    NavigetionViewDetail(model: model)
//                    
//                }
//               
//            })
        }
        .scrollIndicators(.hidden)
        .listStyle(.plain)
    }
}

